package corej.prj.commandlinebank.model;

import corej.prj.commandlinebank.exception.BalanceNotEnoughException;
import corej.prj.commandlinebank.exception.LoanException;

public class LoanSavingAccount extends SavingAccount implements Loanable {
    private double loan;

    public LoanSavingAccount() {
        super();
    }

    public LoanSavingAccount(String password, String name, String personId,
                             String email) {
        super(password, name, personId, email);
    }

    public void requestLoan(double money) {
        this.loan += money;
    }

    public void payLoan(double money) throws LoanException,
            BalanceNotEnoughException {
        if (loan < money) {
            throw new LoanException("����Ҫ����ô��Ǯ");
        }
        this.withdraw(money);
        this.loan -= money;
    }

    public void setLoan(double loan) {
        this.loan = loan;
    }

    public double getLoan() {
        return loan;
    }
}
